package org.dwpd.utils;

import io.jsonwebtoken.*;
import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.UUID;

/**
 * Package:org.dwpd.utils
 *
 * @ClassName:JwtHelper
 * @Create:2024/8/16 13:33
 **/
@Data
@Component
public class JwtHelper {
    //当前程序签名秘钥
    private static final String TOKEN_SIGN_KEY = "HfkjksFKLJISJFKLFKWJFQFIQWIOFJQOFFQGGSDGFFJIQOEUFIEJFIOQWEFHFQOK5FKOIQWUFFEFE423FIQEOFJHUEWHFKASKDLQWJIFSJDJKFHJIJWO";

    public static String createToken(){
        String token = Jwts.builder().setSubject("TOKEN_USER")
                .signWith(SignatureAlgorithm.HS512, TOKEN_SIGN_KEY)
                .compressWith(CompressionCodecs.GZIP)
                .claim("UUID", UUID.randomUUID().toString())
                .compact();
        return token;
    }
}
